$(function(){//歌手图标
    // console.log(result)
    $.ajax({
        type:'Get',
        url:'http://localhost:8088/dev/singer/select',
        async: true,//请求是否异步，默认为异步，这也是ajax重要特性
        data: "",    //参数值
        contentType:"application/json",
        success:function(result){
            if(result.code==200){
                let arr=result.data
                console.log(arr);
                loadData1(arr)
                loadData2(arr)
            }
        }
    })
})
function tjselect() {//左边歌手筛选
    $.ajax({
        type: 'Get',
        url: 'http://localhost:8088/dev/singer/select',
        async: true,//请求是否异步，默认为异步，这也是ajax重要特性
        data: "",    //参数值
        contentType: "application/json",
        success: function (result) {
            if (result.code == 200) {
                let arr = result.data
                loadData1(arr)
            }

        }
    })
}
function rmselect(){
    $.ajax({
        type: 'Get',
        url: 'http://localhost:8088/dev/singer/select',
        async: true,//请求是否异步，默认为异步，这也是ajax重要特性
        data: "",    //参数值
        contentType: "application/json",
        success: function (result) {
            if (result.code == 200) {
                let arr=result.data
                loadData1(arr)
            }
        }
    })
}
function hymanselect(){
    let lia=$(".singertype1").text()
    console.log(lia)
    // $.ajax({
    //     type:'Get',
    //     url:'http://localhost:8088/dev/singer/hynanselect',
    //     async:true,
    //     data: {"xinxi":"lia"},
    //     contentType:"application/json",
    //     success:function (result){
    //         if (result.code == 200) {
    //             let arr=result.data
    //
    //             loadData1(arr)
    //         }
    //     }
    // })
    $.get(`http://localhost:8088/dev/singer/hynanselect/${lia}`,function(result){
        if (result.code == 200) {
            let arr=result.data

            loadData1(arr)
        }
    })
}
function hywanselect(){
    let lia=$(".singertype2").text()
    console.log(lia)
    $.get(`http://localhost:8088/dev/singer/hynvselect/${lia}`,function(result){
        if (result.code == 200) {
            let arr=result.data

            loadData1(arr)
        }
    })
}

function loadData1(arr){
    console.log(arr)

    let str=' <ul class="gsw imgc" id="a">';

    for(let i=0;i<arr.length;i++){
        if (i<10){
        str+=`<li style="display: inline-block;">
                <div class="gsw card1">
                  <a href="http://localhost:8088/dev/views/czn/views/Introduction.html?id=${arr[i].id}&name=${arr[i].singerName}"><img src="../avatar/${arr[i].singerAvatar}"></a>
                </div>
                <p><a href="http://localhost:8088/dev/views/czn/views/Introduction.html?id=${arr[i].id}&name=${arr[i].singerName}">${arr[i].singerName}</a></p>
              </li>`
        }
    }
    str+=`</ul>`;
    $(".list1").html(str);
}
function loadData2(arr){

    let str=' <ul class="gsw imgc1" id="a1">';

    for(let i=0;i<arr.length;i++){
        str+=`<li style="display: inline-block;">
                <div class="gsw card1">
                  <a href="http://localhost:8088/dev/views/czn/views/Introduction.html?id=${arr[i].id}&name=${arr[i].singerName}"><img src="../avatar/${arr[i].singerAvatar}"></a>
                </div>
                <p><a href="http://localhost:8088/dev/views/czn/views/Introduction.html?id=${arr[i].id}&name=${arr[i].singerName}">${arr[i].singerName}</a></p>
              </li>`
    }
    str+=`</ul>`;
    $(".list2").html(str);
}